package com.iteaj.network.client;

import com.iteaj.network.*;
import com.iteaj.network.client.ClientMessage;
import com.iteaj.network.client.IotClient;
import org.springframework.core.GenericTypeResolver;

public interface ClientComponent<M extends ClientMessage> extends FrameworkComponent {

    /**
     * 短线重连时间(秒)
     * 如果值<=0, 则不进行重连
     */
    default long getReconnectTime() {
        return 30;
    }

    IotClient getClient();

    @Override
    default Class<M> getMessageClass() {
        return (Class<M>) GenericTypeResolver.resolveTypeArgument(getClass(), ClientComponent.class);
    }
}
